package com.esun.payment_api.controller;

import com.esun.common.api.CommonResult;
import com.esun.payment_api.domain.SysDictContTask;
import com.esun.payment_api.security.AjaxResult;
import com.esun.payment_api.service.SysDictContTaskService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/sysDictContTask")
public class SysDictContTaskController {

    @Resource
    SysDictContTaskService sysDictContTaskService;

    /**
     * 查询所有任务号字典信息，条件查询
     */
    @GetMapping("/querySysDictContTaskAll")
    public CommonResult querySysDictContTaskAll(Short coId, String keyword, String word) {
        try {
            List<SysDictContTask> list = sysDictContTaskService.selectByExample(coId, keyword, word);
            return CommonResult.success(list, "任务号字典查询成功");
        } catch (Exception e) {
            return CommonResult.failed(e.getMessage());
        }
    }

    /**
     * 添加单个
     */
    @RequestMapping("/addSysDictContTaskOne")
    public AjaxResult addSysDictContTaskOne(@RequestBody SysDictContTask record) {
        try {
            return sysDictContTaskService.insertSelective(record);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }

    /**
     * 根据id删除单个(软删除)
     */
    @RequestMapping("/deleteSysDictContTaskById")
    public AjaxResult deleteSysDictContTaskById(Integer id) {
        try {
            return sysDictContTaskService.deleteById(id);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }

    /**
     * 根据id修改单个
     */
    @RequestMapping("/updateSysDictContTask")
    public AjaxResult updateSysDictContTask(@RequestBody SysDictContTask record) {
        try {
            return sysDictContTaskService.updateByPrimaryKeySelective(record);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }

}
